import { defineConfig, loadEnv } from 'vite';
import uni from '@dcloudio/vite-plugin-uni';
import path from 'path';
// https://vitejs.dev/config/
export default ({ mode }) =>
  defineConfig({
    plugins: [uni()],
    define: { 'process.env': loadEnv(mode, process.cwd()) },
    resolve: {
      alias: {
        '/@': path.resolve(__dirname, 'src'),
        'vue-i18n': 'vue-i18n/dist/vue-i18n.cjs.js'
      }
    },
    server: {
      port: 3000
    },
    build: {
      // chunkSizeWarningLimit: 1000,
      outDir: './dist',
      minify: 'terser',
      cssCodeSplit: true, // 如果设置为false，整个项目中的所有 CSS 将被提取到一个 CSS 文件中
      terserOptions: {
        // 生产环境下移除console
        compress: {
          drop_console: true,
          drop_debugger: true
        }
      }
    }
  });
